import 'package:flutter/material.dart';
import 'package:ivc/model/bizmodel.dart';
import '../../routers/application.dart';
import '../../model/test_data.dart';

class MROrderPage extends StatefulWidget {
  final String id;
  final bool readonly;

  MROrderPage({this.id, this.readonly});
  @override
  MROrderPageState createState() => new MROrderPageState();
}

class MROrderPageState extends State<MROrderPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    //super.build(context);
    String id = this.widget.id;
    MROrder order = TestData.getMROrderById(id);
    return CustomScrollView(shrinkWrap: true, slivers: <Widget>[
      SliverAppBar(
        flexibleSpace: FlexibleSpaceBar(
          background: FadeInImage.assetNetwork(
            placeholder: "assets/images/house.png",
            image: order.engineerAvatar,
          ),
        ),
        primary: true, //是否预留高度
        forceElevated: true,
        automaticallyImplyLeading: true,
        snap: false, //与floating结合使用
        expandedHeight: 200.0, //展开高度
        floating: false, //是否随着滑动隐藏标题
        pinned: true, //是否固定在顶部
        backgroundColor: Colors.lightGreen,
      ),
      SliverToBoxAdapter(
          child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Card(
            color: Colors.blue.withAlpha(30),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                 ListTile(
                  leading: Icon(Icons.album),
                  title: Text(order.title),
                  subtitle: Text('由${order.engineerName}提供维修保养服务'),
                   trailing: Text("全国性服务"),
                ),
                ButtonTheme.bar(
                  child: ButtonBar(
                    children: <Widget>[
                      FlatButton(
                        child: const Text('评价', style: TextStyle(color: Colors.white)),
                        onPressed: () {},
                      ),
                      FlatButton(
                        child: const Text('我要服务', style: TextStyle(color: Colors.white)),
                        onPressed: () {
                          Application.router.navigateTo(context, "/mrnow/${id}");
                          },
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Text(
              "本公司从事机械维修行业10年经历, 服务人员技艺精湛, 服务到位, 风里来雨里去, 随机随到, 为你解决机器遇到的各种问题。\n\n" +
                  "请多多给予平台好评, 多谢\n\n" +
                  "本公司在国庆期间推出大优惠活动, 工时费全免, 部分配件执行8折优惠价 \n ",
              style: TextStyle(fontSize: 16, color: Colors.black54)),
        ],
      )),
    ]);
  }
}
